﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spaanjaars.ContactManager.Infrastructure.Domain;

namespace Spaanjaars.ContactManager.Infrastructure.Validation
{
    /// <summary>
    /// based on the check class from 
    /// 
    /// </summary>
    public sealed class Check
    {                                
        public static void ThrowExceptionIfAnyBrokenRules(IDomainObject domainObject, string checkMessage)
        {
            if (!domainObject.GetBrokenRules().IsEmpty())
                throw new InvalidDomainObjectException(checkMessage, domainObject.GetBrokenRules());
        }

        public static void ThrowExceptionIf(bool assertion, string checkMessage)
        {
            if (!assertion)
                throw new InvalidDomainObjectException(checkMessage, null);
        }
    } 
}
